from django.db import models
from dingxiang.utils.models import BaseModel
# Create your models here.

# 临床决策
class ClinicalSystemModel(BaseModel):
    name = models.CharField(null=True, blank=True, max_length=255, verbose_name="系统名称")

    class Meta:
        db_table = 'clinical_system'
        verbose_name_plural = '临床决策'

    def __str__(self):
        return self.name

# 临床疾病
class ClinicalDiseasesModel(BaseModel):
    name = models.CharField(max_length=255, null=True, blank=True, verbose_name="疾病名称")
    description = models.TextField(null=True, blank=True, verbose_name="疾病描述")
    clinical = models.ForeignKey(ClinicalSystemModel, on_delete=models.DO_NOTHING, null=True, related_name='contents', verbose_name="临床决策")
    class Meta:
        db_table = 'clinical_diseases'
        verbose_name_plural = '临床疾病'

    def __str__(self):
        return self.name

# 临床疾病内容
class ClinicalDiseaseContentModel(BaseModel):
    title = models.CharField(max_length=255, null=True, blank=True, verbose_name="标题")
    publish_date = models.DateField(auto_now_add=True, null=True, blank=True, verbose_name="发表日期")
    author = models.CharField(max_length=255, null=True, blank=True, verbose_name="作者")
    content = models.TextField(verbose_name="疾病内容")
    disease = models.OneToOneField(ClinicalDiseasesModel, on_delete=models.DO_NOTHING, null=True, related_name='contents', verbose_name="临床疾病")
    recomment_home = models.BooleanField(default=False,verbose_name='是否推荐首页栏目')

    class Meta:
        db_table = 'clinical_disease_content'
        verbose_name_plural = '临床疾病内容'

    def __str__(self):
        return f"Content for {self.disease.name}"
